package com.amit.jsp;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(name="test",urlPatterns={"/test.jlc"})
public class TestServlet  extends HttpServlet{
	
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		
		String fnm=request.getParameter("fname");
		String eml=request.getParameter("email");
		
		boolean er=false;
		String page="index.jsp";
		if(fnm==null||fnm.trim().length()==0)
		{
			request.setAttribute("fname", "Name is required");
			er=true;
		}
		if(eml==null||eml.trim().length()==0)
		{
			request.setAttribute("email", "Email is required");
			er=true;
		}
		if(!er)
		
			page="home.jsp";
		request.getRequestDispatcher(page).forward(request, response);
		
		
		
		
	}

}
